package com.util;

import java.io.InputStreamReader;
import java.util.Properties;

public class PropertiesUtil {
    public  static String getStringPro(String key)  {
        try {
            String filePath="config.properties";
            Properties props = new Properties();
            props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(filePath)));
            String value = props.getProperty(key);
            return value;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public  static int getintPro(String key)  {
        try {
            String filePath="config.properties";
            Properties props = new Properties();
            props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(filePath)));
            String value = props.getProperty(key);
            return Integer.parseInt(value);
        } catch (Exception e) {
            e.printStackTrace();
            return -1000;
        }
    }
    public  static boolean getbooleanPro(String key)  {
        try {
            String filePath="config.properties";
            Properties props = new Properties();
            props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(filePath)));
            String value = props.getProperty(key);
            return Boolean.valueOf(value);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
